#ifndef INTEGER_FORMATTER_H
#define INTEGER_FORMATTER_H
class IntegerFormatter; // Ping pong
#include <iostream>
#include "OutFormatter.h"
#include "InFormatter.h"
#include <string>

class IntegerFormatter
{
    friend std::ostream & operator<<(std::ostream & stream, OutFormatter const & formatter);
    friend std::istream & operator>>(std::istream & stream, InFormatter & formatter);

private:
    int _width;
    int _base;
    char _padding;
    std::ios_base::fmtflags _adjustment;
    bool _caseInsensitive;
    bool _upperCase;
    bool _showBase;

public:
    IntegerFormatter(void);
    ~IntegerFormatter(void);

    // Some actions which effectively can do the same as a stream manipulator
    IntegerFormatter & setWidth(int base);
    IntegerFormatter & setPadding(char padding);
    IntegerFormatter & setUpperCase(bool upper = true);
    IntegerFormatter & setLowerCase(bool lower = true);
    IntegerFormatter & setShowBase(bool show = true);
    IntegerFormatter & setNoShowBase(bool noShow = true);
    IntegerFormatter & setIgnoreCase(bool ignore = true);
    
    // These handles the position of padding 
    // (notice that e.g. left means that the integer is flushed left, NOT padded on the left)
    IntegerFormatter & setAdjust(std::ios_base::fmtflags flag);
    IntegerFormatter & adjustLeft();
    IntegerFormatter & adjustRight();
    IntegerFormatter & adjustInternal();

    //Choose base of integer (2-36)
    IntegerFormatter & setBase(int base);

    OutFormatter out(int value) const;
    InFormatter in(int & value) const;

    char digitValue(int digit) const;
    int valueDigit(char digit) const;

};

#endif // INTEGER_FORMATTER_H